<template>
  <el-container class="h-100" v-loading="loading">
    <el-header class="shadow-sm d-flex justify-content-center bg-white" style="height: 80px;">
      <div class="w-100" style="line-height: 80px;">
        <h5 class="d-inline">外网作业过程监管</h5>
        <div class="float-right">
          <!-- 图斑和地类样本 -->
          <el-select @change="changedSearch" placeholder="请选择" v-model="value" class="my-2" size="small">
            <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
            </el-option>
          </el-select>
          <!-- 只选择市 -->
          <el-select @change="changedSearch" v-model="cityId" placeholder="请选择市" size="small"
            clearable>
            <el-option v-for="(val, key) in citys" :filterable="true" :key="key" :label="val"
              :value="key">
            </el-option>
          </el-select>
          <el-button type="primary" class="ml-3" @click="exportExcel" size="small">报表导出<i class="el-icon-download"></i></el-button>
        </div>
      </div>
    </el-header>
    <el-main class="m-2 bg-white">
      <el-table :data="datas">
        <el-table-column prop="date" label="序号" width="60" align="center" type="index">
        </el-table-column>
        <el-table-column prop="name" label="地市" width="80" align="center">
        </el-table-column>

        <el-table-column label="县级工作" align="center" v-if="value !== 'Wyhc'">
          <el-table-column prop="total" label="总任务" align="center">
          </el-table-column>
          <el-table-column prop="areaYjz" label="已举证" align="center">
          </el-table-column>
          <el-table-column prop="areaDsh" label="待审核" align="center">
          </el-table-column>
          <el-table-column prop="areaYtg" label="已通过" align="center">
          </el-table-column>
          <el-table-column prop="areaWtg" label="未通过" align="center">
          </el-table-column>
          <el-table-column prop="areaCxjz" label="重新举证" align="center">
          </el-table-column>
          <el-table-column prop="areaYsb" label="县级已上报" align="center" width="100">
          </el-table-column>
        </el-table-column>

        <el-table-column label="市级工作" align="center" v-if="value !== 'Wyhc'">
          <el-table-column prop="cityDsh" label="待审核" align="center" width="100">
          </el-table-column>
          <el-table-column prop="cityYtg" label="已通过" align="center" width="100">
          </el-table-column>
          <el-table-column prop="cityWtg" label="未通过" align="center" width="100">
          </el-table-column>
          <el-table-column prop="cityYsb" label="市级已上报" align="center" width="100">
          </el-table-column>
        </el-table-column>

        <el-table-column label="省级核查人员工作" align="center">
          <el-table-column prop="provinceDsh" label="待初审" align="center">
          </el-table-column>
          <el-table-column prop="provinceYtg" label="初审已通过" align="center">
          </el-table-column>
          <el-table-column prop="provinceWtg" label="初审未通过" align="center">
          </el-table-column>
          <el-table-column prop="provinceYw" label="待定" align="center">
          </el-table-column>
          <!-- <el-table-column prop="provinceWsb" label="未上报" align="center">
          </el-table-column> -->
          <el-table-column prop="provinceYsb" label="已上报" align="center">
          </el-table-column>
        </el-table-column>
        <el-table-column label="省级核查负责人工作" align="center">
          <el-table-column prop="level2Dsh" label="待复审" align="center">
          </el-table-column>
          <el-table-column prop="level2Ytg" label="复审已通过" align="center">
          </el-table-column>
          <el-table-column prop="level2Wtg" label="复审未通过" align="center">
          </el-table-column>
          <!-- <el-table-column prop="level2Wsb" label="未上报" align="center">
          </el-table-column> -->
          <el-table-column prop="level2Ysb" label="已上报" align="center">
          </el-table-column>
        </el-table-column>
      </el-table>
    </el-main>
  </el-container>
</template>
<script>
import axios from "axios";
import pca from '@/libs/pca-code'
// import getDatas from '../common/ctiyCountyDatas'

export default {
  name: "works-chedule",
  title: "外网作业过程监管",
  data() {
    return {
      loading: false,
      value: "Spot",
      options: [
        {
          value: "Spot",
          label: "初次举证"
        },
        {
          value: "Sample",
          label: "地类样本"
        },
        {
          value: "Wyhc",
          label: "外业核查"
        },
        {
          value: "Bcjz",
          label: "补充举证"
        }
      ],
      datas: [],
      // citys: [],
      cityId: ''
    };
  },
  mounted() {
    this.changedSearch()
    // this.getCtiy(this.url)
  },
  methods: {
    changedSearch() {
      this.loading = true;
      let url = `analysis/spot/get${this.value}ProgressStatistical?provinceId=610000&cityId=${this.cityId ? this.cityId : ''}`
      if (this.value === 'Wyhc') {
        url = `analysis/hc/spot/getWyhcProgressStatistical?provinceId=610000&cityId=${this.cityId ? this.cityId : ''}`
      } else if (this.value === 'Bcjz') {
        url = `analysis/bc/spot/getSpotProgressStatistical?provinceId=610000&cityId=${this.cityId ? this.cityId : ''}`
      }
      axios.get(url, {}).then(res => {
        if (res.data.code === '200') {
          this.datas = res.data.data
        } else {
          this.$codeError(res)
        }
      }).catch(error => {
        this.$catchError(error);
      }).finally(() => {
        this.loading = false;
      });
    },
    // getCtiy () {
    //   getDatas(this, 'survey/areaInfo/getCityInfo').then((citys) => {
    //     this.citys = citys
    //     this.city = this.citys[0]
    //   })
    // },
    exportExcel() {
      this.$exportExcel(`analysis/downExcel/down${this.value}ProgressStatisticalExcel?provinceId=610000&oauth=${this.$store.state.user.user.oauth}&cityId=${this.cityId ? this.cityId : ''}`)
    }
  },
  computed: {
    citys() {
      return pca[610000]
    }
  }
};
</script>